function level1Change(obj){
	//获得1级分类的id
	var parentId = $(obj).val();
	//ajax
	$.ajax({
		url:"/ssm_app/devApp/findLevel",
		data:"{\"parentId\":\""+parentId+"\"}",
		type:"post",
		success:function(data){
			var content = "<option value=''>-- 请选择 --</option>";
			var level3 = $("#level3");
			level3.html(content);
//			2级jquery对象
			var level2 = $("#level2");
			for(var i = 0;i < data.length;i++){
				content += "<option value="+data[i].id+">"+data[i].categoryname+"</option>"
			}
			level2.html(content);
		},
		datatype:"json",
		contentType:"application/json;charset=utf-8"
	});
}

function level2Change(obj){
	//获得1级分类的id
	var parentId = $(obj).val();
	//ajax
	$.ajax({
		url:"/ssm_app/devApp/findLevel",
		data:"{\"parentId\":\""+parentId+"\"}",
		type:"post",
		success:function(data){
			var level3 = $("#level3");
			var content = "<option value=''>-- 请选择 --</option>";
			for(var i = 0;i < data.length;i++){
				content += "<option value="+data[i].id+">"+data[i].categoryname+"</option>"
			}
			level3.html(content);
		},
		datatype:"json",
		contentType:"application/json;charset=utf-8"
	});
}





//分页
function page(num){
	//给currentPage赋值
	$("#currentPage").val(num);
	//提交表单
	$("#demo-form2").submit();
}


//新增的时候异步校验apkName是否唯一
function checkApkname(obj){
	var apkname = $(obj).val();
	$.ajax({
		url:"/ssm_app/devApp/checkApkName",
		data:"{\"apkname\":\""+apkname+"\"}",
		type:"post",
		success:function(data){
			if(data.apkInfo != "0"){
				//不可以使用
				$("#apknameInfo").html("apk名字重复..");
				$("#apknameInfo").css("color","red");
			}
		},
		datatype:"json",
		contentType:"application/json;charset=utf-8"
	});
	
}



function appInfoUpdate(obj){
	//获得状态的id
	var status = $(obj).attr("appInfoStatus");
	//只有待审核 1 和审核未通过3 才可以修改
	if(!(status == 1 || status == 3)){
		//不可以修改
		alert("只有待审核和审核未通过的app才可以修改");
		return ;
	}
	//获取app的id
	var id = $(obj).attr("appInfoId");
	//跳转到controller中
	location.href="/ssm_app/devApp/disAppInfoUpdate/"+id;
}




function changeImg(obj){
	$(obj).next().css("display","block");
	$(obj).prev().css("display","none");
	$(obj).css("display","none");
}

function appInfoUpdateVersion(obj)
{
	//获得状态id
	var status=$(obj).attr("appInfoStatus");
	//只有待审核 1 和审核未通过3 才可以修改
	if(!(status == 1 || status == 3)){
		//不可以修改
		alert("只有待审核和审核未通过的app才可以修改");
		return ;
	}
	//获取app的id
	var id = $(obj).attr("appInfoId");
	//跳转页面
//	location.href="/ssm_app/devApp/disAppInfoUpdateVersion/"+id;
	$.ajax({
		url:"/ssm_app/devApp/checkVersion",
		data:{"appid":id},
		type:"post",
		datatype:"text",
		success:function(data){
			if(data=="false"){
				alert("没有版本信息，请新增后进行修改");
			}else
			{
				location.href="/ssm_app/devApp/disAppInfoUpdateVersion/"+id;
			}
		},
	});
}


function del(obj) {
	var msg = "您真的确定要删除吗？\n\n请确认！";
	var appid=$(obj).attr("appInfoId");
	if (confirm(msg)==true){
		location.href="/ssm_app/devApp/delAppInfo/"+appid;
	}else{
		
	}
	}










//上架
function appStatusNameUpdateUp(obj){


	var id = $(obj).attr("appInfoId");
	$.ajax({
		url:"/ssm_app/devApp/appStatusNameUpdateUp",
		data:"{\"id\":\""+id+"\"}",
		type:"post",
		success:function(data){
			if(data.status==0){
				//修改成功
				location.href="/ssm_app/devApp/appInfoList/";
				
			}else{
			//修改失败
			}
		},
		datatype:"json",
		contentType:"application/json;charset=utf-8"
	});
	
}	
//下架	
	function appStatusNameUpdateDown(obj){
		
			
			var id = $(obj).attr("appInfoId");
			$.ajax({
				url:"/ssm_app/devApp/appStatusNameUpdateDown",
				data:"{\"id\":\""+id+"\"}",
				type:"post",
				success:function(data){
					if(data.status==0){
						//修改成功
						location.href="/ssm_app/devApp/appInfoList/";
						
					}else{
					//修改失败
					}
				},
				datatype:"json",
				contentType:"application/json;charset=utf-8"
			});
			
			  
	}








